﻿//---------------------------------------------------------------------------

#ifndef MainH
#define MainH
#include <System.Classes.hpp>
#include <Vcl.Buttons.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.Dialogs.hpp>
#include <Vcl.ExtCtrls.hpp>
#include <Vcl.ExtDlgs.hpp>
#include <Vcl.Grids.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Mask.hpp>

#include <memory>
#include "PLFinder.h"

//---------------------------------------------------------------------------
class TFormMain : public TForm
{
__published:	// IDE-managed Components
	TButton *Button1;
	TDrawGrid *DrawGrid1;
	TOpenTextFileDialog *OpenTextFileDialog1;
	TButton *Button2;
	TRadioGroup *RadioGroup1;
	TEdit *Edit1;
	TLabel *Label1;
	TLabel *Label3;
	TBitBtn *BitBtn1;
	TButton *Button3;
	TImage *Image1;
	TLabel *Label2;
	TLabel *Label4;
	TLabel *Label5;
	TLabeledEdit *LabeledEdit1;
	TLabel *Label6;
	void __fastcall Button1Click(TObject *Sender);
	void __fastcall Button2Click(TObject *Sender);
	void __fastcall BitBtn1Click(TObject *Sender);
	void __fastcall Button3Click(TObject *Sender);
	void __fastcall DrawGrid1DrawCell(TObject *Sender, System::LongInt ACol, System::LongInt ARow,
		  TRect &Rect, TGridDrawState State);
	void __fastcall DrawGrid1SelectCell(TObject *Sender, System::LongInt ACol, System::LongInt ARow,
          bool &CanSelect);

private:	// User declarations
	int CurrCol, CurrRow;
	int PLGridNoInterval;      	// 画X时的间隔
	int PLGridCharHeight;       // 字高
	int PLGridCharWidth;       // 字宽

	std::unique_ptr<PLFinderBase> plFinder;

	void DrawAFlag(const Flag& f, int x, int y);
	void InitGrids();
	int proc(bool clear);
	void DrawStep(int col, int row);

	bool UICallback(int n, bool isCol, int steps, int exhanum);

public:		// User declarations
	__fastcall TFormMain(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TFormMain *FormMain;
//---------------------------------------------------------------------------
#endif
